import http from "@/utils/http";
import type { AnnexCategoryItem, AnnexTemplateItem } from "./type";

/**
 * 获取工程资料分类列表
 */
export const getAnnexCategoryList = () => {
  return http.get<AnnexCategoryItem[]>("/crm/buildserver/construction/profile/categoryList");
};

/**
 * 获取工程资料模板
 */
export const getAnnexTemplateList = (categoryId: string) => {
  return http.get<AnnexTemplateItem[]>(`/crm/buildserver/construction/profile/templateList/${categoryId}`);
};
/**
 * 删除分类
 */
export const deleteAnnexCategory = (categoryId: string) => {
  return http.deleteMethod(`/crm/buildserver/construction/profile/category/${categoryId}`);
};

/**
 * 新增分类
 */
export const addAnnexCategory = (data: AnnexCategoryItem) => {
  return http.post(`/crm/buildserver/construction/profile/category/add`, data);
};

/**
 * 修改模板
 */
export const updateAnnexConfig = (data: AnnexTemplateItem[], categoryId: string) => {
  return http.post(`/crm/buildserver/construction/profile/update/${categoryId}`, data);
};

/**
 * 分类排序
 */
export const updateAnnexCategorySort = (data: string[]) => {
  return http.post(`/crm/buildserver/construction/orderNumCategory`, data);
};

/**
 * 修改是否审批
 */
export const updateAnnexConfigApproval = (data: AnnexCategoryItem) => {
  return http.post(`/crm/buildserver/construction/profile/category/update`,data);
};